home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / ac2viv.zip / AC2VIV.DOC next >
Text File  |  1992-04-14  |  18KB  |  659 lines

  1.  
  2.                        AC2VIV 1.0
  3.  
  4.      Autocad Release 11 to Vivid 2.0 Translator
  5.  
  6.  
  7. April, 1992
  8. Copyright 1992 by Roy Hirshkowitz
  9.  
  10.  
  11. TABLE OF CONTENTS
  12.  
  13.  
  14. INTRODUCTION...........................2
  15.  
  16. GETTING STARTED........................3
  17.  
  18. 1.  CREATING A 3-D MODEL...............4
  19.  
  20.     A.  LAYER USAGE....................4
  21.     B.  SPECIAL VIVID BLOCKS...........5
  22.     C.  STANDARD AUTOCAD ENTITIES......6
  23.  
  24. 2.  ADDING STUDIO & LIGHTS.............9
  25.  
  26.     A.  STUDIO STRUCTURE...............9
  27.     B.  LIGHTS........................10
  28.  
  29. 3.  VIEWING THE MODEL.................11
  30.  
  31. 4.  RUNNING THE TRANSLATOR............11
  32.  
  33.                     
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54. Autocad and Autolisp are registered trademarks of Autodesk, Inc.
  55. Vivid 2.0 is copyright Steven B. Coy
  56.  
  57.  
  58.  
  59.                        -1-
  60.  
  61.                     INTRODUCTION
  62.  
  63.  
  64. AC2VIV is designed to work in conjunction with Autocad R11 and Stephen
  65. Coy's (Vivid Software) raytracer Vivid 2.0.  Some familiarity with both
  66. of these programs is assumed.  It is heartily recommended that the 386
  67. specific versions of both of these programs be used.  Further hearty
  68. recommendations include a minimum of 8 MB memory and plenty of play
  69. space on your hard disk, although all of the programs will work with
  70. less.
  71.                       
  72.  
  73. AC2VIV is a collection of Autolisp routines and support files designed
  74. to translate Autocad R11 drawings into Vivid input files.  The
  75. translator works within the drawing editor session and currently
  76. provides a nearly complete "front-end" for Vivid.  By making use of
  77. this translator, a user is able to construct a 3d-model, select a
  78. viewpoint, add lights and specify a Vivid studio structure, all within
  79. Autocad.  At this time, surface definitions must still be generated
  80. outside of Autocad as text files, although future releases may remedy
  81. this.
  82.  
  83. Files included in this package:
  84.  
  85. AC2VIV.LSP        The Autolisp translation routines.
  86.  
  87. AC2VIV.DOC        This document.
  88.  
  89. LICENSE.DOC       Registration information
  90.  
  91. V_STUDIO.DWG      Autocad dwg file containing the studio definition.
  92.  
  93. L_DIRECT.DWG      Autocad dwg files of light definitions.
  94. L_POINT.DWG
  95. L_SPOT.DWG
  96. L_SPHERE.DWG
  97.  
  98.  
  99. V_SPHERE.DWG      Autocad dwg files of special Vivid primitives.
  100. V_DISK.DWG
  101. V_DISK2.DWG
  102. V_CONE##.DWG
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.                       
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.                           -2-
  120.  
  121.  
  122.  
  123.                     GETTING STARTED
  124.  
  125.  
  126.  
  127.  
  128. AC2VIV is loaded by typing:
  129.  
  130.      (LOAD "AC2VIV")
  131.  
  132. at the command prompt or by appending it to ACAD.LSP for automatic
  133. loading.  It is invoked by typing:
  134.  
  135.      AC2VIV
  136.  
  137.  
  138. The process of building, translating and rendering a model usually goes
  139. something like this:
  140.  
  141.  
  142.  
  143. 1.  A 3d-model is created in AutoCAD.
  144.  
  145. 2.  Lights and a studio structure are added to the model.
  146.  
  147. 3.  A perspective view of the model is created using Autocad's DVIEW    
  148.     command.
  149.  
  150. 4.  The translation is run and a Vivid input file produced.
  151.  
  152. 5.  Autocad is exited and surface definitions created.
  153.  
  154. 6.  Vivid is executed with the .v file created by AC2VIV.
  155.  
  156.  
  157. The first four of these steps are explored in more detail in the pages
  158. which follow.  For help with the last two, refer to VIVID.DOC, the
  159. manual included with the Vivid executables.
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.                            -3-
  179.  
  180.  
  181.  
  182.                     1. CREATING A 3-D MODEL
  183.  
  184.  
  185. AC2VIV currently recognizes almost all of Autocad's 3d entities as well
  186. as some special Vivid primitives (for a complete listing of these see
  187. below.)  
  188.  
  189.  
  190.  
  191.  
  192.  
  193. A.  LAYER USAGE
  194.  
  195.  
  196. It is crucial when building a model designed for input to this
  197. translator, that careful attention is paid to the layers on which
  198. entities are drawn.  In the Vivid input file which is produced from the
  199. model, your layer names will stand for different materials.  For
  200. example, if the model has a layer called STEEL, all the entities on
  201. that layer will follow the surface definition for STEEL.  The
  202. translator accomplishes this by adding the line:
  203.  
  204. #include STEEL.VS 
  205.  
  206.     
  207. to the Vivid input file.  Vivid will then look for a text file called
  208. STEEL.VS which should contain an appropriate surface definition for
  209. steel. Currently these .vs files must be created outside of Autocad,
  210. using a text editor.  <<LAYER NAMES CONTAINING 3D ENTITIES SHOULD BE 8
  211. CHARACTERS OR LESS,>> since they will be used by Vivid as DOS filenames
  212. when it searches for material definitions.  
  213.  
  214. If dependent layer names are present from Xrefs contained within the
  215. drawing, the dependent portion of the layer name will be stripped out,
  216. and only the main layer name used for a surface definition.  I.e. an
  217. entity on layer TEST1|TEST3|STEEL will appear after the same surface
  218. definition as an entity on layer STEEL. 
  219.  
  220. If blocks are inserted which contain entities drawn on layer 0, those
  221. entities will be "transparent", i.e. they will appear after the surface
  222. definition of the layer on which the block was inserted.  For example
  223. if a block is inserted on layer STEEL, all of its entities which are
  224. drawn on layer 0 will appear after the surface definition for STEEL.
  225.  
  226. Currently Vivid 2.0 does not permit leading numerals or "-" characters
  227. to appear in filenames.  Therefore layer names such as "0", "1STEEL",
  228. or "STEEL-1" will not generate valid input.
  229.  
  230.  
  231. <<ONLY LAYERS WHICH ARE THAWED AND ON WILL BE USED FOR TRANSLATION>>
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.                             -4-           
  239.  
  240.  
  241. B. SPECIAL VIVID BLOCKS
  242.  
  243. Vivid provides some geometric primitives which do not correspond
  244. directly to Autocad entities.  These include spheres, rings and cones. 
  245. While similar looking objects can be constructed in Autocad using
  246. meshes, these objects will translate into a large number of Vivid
  247. primitives, making them inefficient.  In addition, because these
  248. objects are composed of individual facets (even after "smoothing" {see
  249. below}), the results are often not as good as with the original
  250. primitive.  For example, using Autocad's 3d.lsp routines, the standard
  251. "sphere" is constructed out of a 16 x 16 mesh.  In order to produce a
  252. smooth appearing object, this pseudo-sphere needs to be translated into
  253. approx. 500 triangular patches.  Even after doing this, the resulting
  254. object will cast "faceted" shadows.  In contrast, using a true Vivid
  255. sphere only one primitive is provided, and the shadows it casts will be
  256. smooth.  
  257.  
  258. To implement some of these Vivid primitives, AC2VIV recognizes certain
  259. block names as containing special geometric information.  These blocks
  260. are included as separate .dwg files, each one containing an Autocad
  261. mesh representation of the Vivid primitive.  In order for these blocks
  262. to work properly they must not be renamed.  If they are renamed, AC2VIV
  263. will treat them like any other mesh and translate them accordingly.
  264.  
  265. The blocks can be scaled, rotated, moved, and inserted into a UCS with
  266. any arbitrary orientation.  The x y and z scale factors must be equal.
  267.  
  268. Currently the recognized blocks are:
  269.  
  270.  
  271. <V_SPHERE>
  272.  
  273. This is a sphere with a radius of 1.
  274.  
  275. <V_DISK>
  276.  
  277. This is a flat disk.  It translates to a Vivid ring with an inner
  278. radius of 0.  
  279.  
  280. <V_DISK2>
  281.  
  282. This is a half disk, otherwise identical to V_DISK
  283.  
  284.  
  285. <V_CONE##>
  286.  
  287. These blocks are pointy Vivid cones with a base radius of 1 and an apex
  288. radius of 0.  The ratio of the height of the cone to its radius is
  289. given by #-- i.e. v_cone4 is a cone whose height is 4 units.
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.                                    
  299.                                  -5-
  300.  
  301. C.  STANDARD AUTOCAD ENTITIES
  302.  
  303. (In the discussion which follows, the Autocad definitions of the terms
  304. "thickness" and "width" are used:  "thickness" refers to extrusion
  305. depth and "width" refers to 2dpolylines and is a planar attribute.)
  306.  
  307.  
  308. Nearly all Autocad surfaces are translated into Vivid primitives. 
  309. Entities which do not have surfaces, such as lines (without thickness),
  310. points, text entities, etc. are ignored.  Blocks and nested blocks ARE
  311. supported.  Currently, the following entities are <<NOT>> translated:
  312.  
  313. <spline or curve fit entities>
  314.  
  315. <2dpolylines with variable width arcs>-- arcs with constant widths,
  316. including thick and wide arcs are translated. 
  317.  
  318. <circles w/ thicknesses of 0>-- Although Autocad treats circles as
  319. surfaces, AC2VIV does not.  Thick circles are translated into Vivid
  320. cylinders (cones) but their ends are not "capped" as they are in
  321. Autocad. Circular surfaces can be modelled using the v_disk block (see
  322. above), and cylinders can be capped in the same way.  This
  323. implementation was chosen because it allowed easy creation of cylinders
  324. without caps.
  325.  
  326.  
  327.  
  328. AC2VIV will recognize and translate the following Autocad standard
  329. entities:
  330.  
  331. <3dfaces>
  332.  
  333. 3dfaces will be translated to Vivid polygons.  Since it is  possible
  334. under Autocad to create 4-sided 3dfaces whose vertices do not lie on a
  335. plane, when this situation is detected, the translator will split the
  336. 3dface into two 3-sided polygons.
  337.  
  338.  
  339. <Lines>
  340.  
  341. Thick lines will be translated into Vivid polygons.
  342.  
  343.  
  344. <2dpolylines>
  345.  
  346. 2dpolylines which are thick, wide or both are translated into Vivid
  347. polygons.  If a polyline is both thick and wide, surfaces are placed at
  348. the "ends", "tops", and "bottoms" as well.  If a polyline contains arcs
  349. of constant width these are translated into clipped cones and rings.
  350. (Donuts will translate fine.)  Variable width arcs are not currently
  351. supported.
  352.  
  353. <Circles>
  354.  
  355. Circles with thickness are translated to Vivid cones w/ a single radius
  356. (cylinders).   The ends are not capped, use v_disk blocks (see above)
  357. to cap them.
  358.  
  359.                               -6-
  360.  
  361.  
  362. <Arcs>
  363.  
  364. Arcs with thickness are translated to clipped Vivid cones (cylinders).
  365.  
  366.  
  367. <Solids>
  368.  
  369. Both solids and solids with thickness are translated into Vivid
  370. polygons.  Thick solids have "tops", "bottoms", "ends" and "sides".
  371.  
  372.  
  373. <Meshes>
  374.  
  375. Both 3d_meshes and polyface meshes (the type produced by AME) are
  376. translated.  By default, meshes are translated as 3 or 4-sided Vivid
  377. polygons.  Meshes can also be tagged as "smoothed", in which case they
  378. will translate as Vivid patches, causing them to appear as smooth
  379. surfaces in the final output.  Blocks can also be tagged as "smoothed",
  380. in which case every mesh included within the block will be smoothed. 
  381. AC2VIV provides the following Autocad commands for manipulating meshes
  382. (these are entered at the command prompt) :
  383.  
  384.  
  385.   facet-- Translate all meshes or blocks in a selection set as faceted  
  386.          (default.)
  387.  
  388.   smooth-- Translate all meshes or blocks in a selection set as smooth  
  389.           objects.
  390.  
  391.   smooth?-- Report the status of a selected mesh.
  392.  
  393.  
  394. <<SOME IMPORTANT CONSIDERATIONS WHEN SMOOTHING MESHES>>
  395.  
  396. *  There is a significant performance penalty for translating large
  397. meshes as smooth objects.  For example, a 50 x 50 mesh on a 486-33 w/
  398. 16 MB of memory took approximately 40 minutes to translate as a smooth
  399. object.  The same mesh translated as a faceted object in under 3
  400. minutes.  This performance penalty is greatly exaggerated if system
  401. memory is at a premium and Autocad must make frequent use of the swap
  402. file.
  403.  
  404. * Currently AC2VIV will not recognize any sharp corners in a smoothed
  405. mesh and will try to make them round.  If your mesh contains many sharp
  406. corners it may actually create some geometrically inconsistent surfaces
  407. which will confuse Vivid.  This problem will be cleaned up in
  408. subsequent releases, but currently the only workaround is to split
  409. meshes with sharp corners into separate meshes.
  410.  
  411. * The objects which are created in Vivid are not true curves, the way
  412. that light interacts with the surface will make them appear curved, but
  413. shadows which they cast. and shadows which are cast upon them will be
  414. faceted. This is normally not a problem but is something that should be
  415. kept in mind.  Wherever possible make use of the "v_" blocks provided
  416. to create true smooth primitives (see above.)
  417.  
  418.                                 -7-
  419.  
  420.  
  421. <Blocks>
  422.  
  423. All Autocad blocks and nested blocks are supported, including Xrefs. 
  424. Blocks can be mirrored, rotated, moved, and placed in any UCS
  425. orientation.  They can also be scaled provided that the scale factor is
  426. uniform for the X Y and Z axes (mirroring does not present a problem.)
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.                          -8-
  479.  
  480.  
  481.                2.  ADDING THE STUDIO & LIGHTS
  482.  
  483.  
  484. A.  STUDIO STRUCTURE
  485.  
  486.  
  487. A studio structure is added to the 3d model by inserting the block
  488. V_STUDIO.  This block comes in with attributes which define the studio
  489. structure.  Most of the Vivid studio structure is supported at this
  490. time.  (See below for items not currently supported.) Their values are
  491. strictly text-- to respond to the UP parameter, for example, simply
  492. type in a value such as "0 0 1" at the Autocad attribute prompt or
  493. attribute entry dialogue box.  
  494.  
  495. The scale and position of the studio structure are irrelevant, although
  496. the "icon" is only a unit or two wide and may need to be scaled up to
  497. be visible (or down to be less obtrusive).  The studio block does not
  498. need to be visible in the scene, <<BUT IT MUST NOT BE ON A LAYER WHICH
  499. IS OFF OR FROZEN>>.  Only the first V_STUDIO block encountered by the
  500. translator will be processed, so be careful not to insert it more than
  501. once or you may get some unexpected results.  If no studio block is
  502. inserted, there is a hard-coded default.  The V_STUDIO block should not
  503. be renamed.
  504.  
  505. Due to the nature of the Autocad attribute format, several parameters
  506. are slightly different than they are in their native Vivid input
  507. format.  These are the switches such as "NO_EXP_TRANS" or "JITTER."  An
  508. attribute value of "Y" or "YES" will cause these switches to be present
  509. in the Vivid input file, values of "N" or "NO" will cause them to be
  510. absent.
  511.  
  512.  
  513. The translator also adds the line 
  514.  
  515. #include color.vc
  516.  
  517. before the studio structure.  This permits use of Vivid's standard
  518. color definitions, but requires that the color file be present in the
  519. working directory when Vivid is run.
  520.  
  521. The following items in the studio are <<NOT>> currently supported by
  522. this version of AC2VIV:
  523.  
  524. *  The orthographic projection and the corresponding "width" parameter
  525.  
  526. *  The "aperture", "focal_length", and "samples" group of parameters.  
  527.  
  528. *  "stop" and "start" line parameters. (These are available as command  
  529.    line switches in Vivid 2.0.)
  530.  
  531. All of these may be manually added to the .v file produced by the
  532. translator using a text editor.
  533.  
  534.  
  535.  
  536.  
  537.  
  538.                               -9-
  539.  
  540.  
  541.  
  542. B.  LIGHTS
  543.  
  544.  
  545. Lights are brought in much the same way as the studio structure.  Four
  546. blocks whose name begins with "L_" denote the four types of lights
  547. available in Vivid.  Each of these blocks contain appropriate
  548. attributes for the particular light they represent.  Similar to the
  549. studio structure, the Vivid switches "NO_SHADOWS" and "NO_SPEC" use "Y"
  550. or "N" attribute values to determine their presence or absence in the
  551. .v input file.
  552.  
  553. <L_POINT>
  554.  
  555. This is Vivid's point light source.  Its position is determined by the
  556. insertion point of the block.  The scale factor of the block is
  557. ignored.
  558.  
  559. <L_DIRECT>
  560.  
  561. This is Vivid's directional light source.  Its position and scale
  562. factor are both ignored.  The direction is given as text input, the
  563. orientation of the block does not affect this.
  564.  
  565. <L_SPOT>
  566.  
  567. This is Vivid's spot light.  It's position is given by the insertion
  568. point, but its direction is currently specified by text, not by the
  569. light's orientation.  The scale factor is ignored.
  570.  
  571. <L_SPHERE>
  572.  
  573. This is Vivid's spherical light source.  Its radius is determined by
  574. the block's scale factor, and its position by the insertion point.
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.                              -10-
  599.  
  600.                      3.  VIEWING THE MODEL
  601.  
  602.  
  603. Before running the translator a perspective view of the model must be
  604. created using the Autocad DVIEW command.  If you are working with
  605. multiple viewports, the viewport containing the view you wish to render
  606. (a perspective view) must be made current.  If you are working in
  607. paperspace, the MSPACE command must first be issued and the desired
  608. viewport made current.  
  609.  
  610. Provided a "flat" projection, an "up" vector of 0 0 1, and a
  611. "resolution" and "aspect" ratio close to your screen are provided to
  612. Vivid via the studio structure, the resulting Vivid image will closely
  613. match the view created within Autocad.  Any lens length (DVIEW ZOOM)
  614. should translate reasonably accurately.  Here are some potential
  615. problems: 
  616.  
  617. *  Autocad only supports one projection, a 3-point perspective similar
  618. to Vivid's "flat" projection.  Using one of Vivid's other methods will
  619. yield varying results.  The "spherical" projection will differ
  620. significantly from the Autocad image. The "orthographic" projection is
  621. currently not supported by the translator.  The "parallax" , or 2-point
  622. perspective, will yield an image which is still reasonably close to the
  623. Autocad view, and any discrepancies are usually predictable.
  624.  
  625. *  Using Autocad's VIEWTWIST option or Vivid's option of UP vectors
  626. other than "0 0 1" may result in unpredictable views.
  627.  
  628. *  Using Vivid aspect ratios other than your screen's aspect ratio
  629. (usually 1.333), or resolution sizes which differ significantly from
  630. your screen aspect ratio, will cause the Vivid view to render
  631. differently than the Autocad view.  These discrepancies are normally
  632. predictable, so this may not prove to be too troublesome.
  633.  
  634.  
  635.  
  636.  
  637.  
  638.                        4.  RUNNING THE TRANSLATOR
  639.  
  640.  
  641. The translator is run by typing AC2VIV at the command prompt.  An
  642. output file name will be requested and the translator will append a
  643. ".v" file extension to the name provided.  There is no check to see if
  644. the file exists already, so be careful not to overwrite anything
  645. important.  The translator will step through the drawing database and
  646. return a statistics screen upon completion, giving information about
  647. the number and types of Autocad entities, and their resultant Vivid
  648. primitives.  The translation time is also reported.
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.                                -11-
  659.